﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TSqlServer;
/// <summary>
/// TVote 的摘要说明
/// </summary>
public class TVote:TData
{

    //常量
  	const string CTableName="t_vote";
    const string CKeyName = "id";
    //与数据表字段对应的变量
    private string FId ; 
    private DateTime FInTime ; 
    private int FIId ; 
    private string FTitle ; 
    private string FDescription ; 
    private int FType ; 
    private DateTime FEndTime ; 
    private int FAuthority ;
    private int FVoters;
    private int FStatus ; 
    private decimal FSortNum ; 
    private string FInMan ; 

	public TVote()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
        FTableName = CTableName;
        FKeyName = CKeyName;
	}
    public TVote(string sid)
    {
    	FTableName = CTableName;
        FKeyName = CKeyName;
        FKeyValue = sid;
    }

    public override void Select()
    {
        string strSql = GetSelectString();
        TSqlDB oDB = new TSqlDB(strSql);
        if (!oDB.EOF)
        {

            FId = oDB["id"].ToString();
            FInTime = oDB["intime"].ToDateTime();
            FIId = oDB["iid"].ToInt();
            FTitle = oDB["title"].ToString();
            FDescription = oDB["description"].ToString();
            FType = oDB["type"].ToInt();
            FEndTime = oDB["endtime"].ToDateTime();
            FAuthority = oDB["authority"].ToInt();
            FVoters = oDB["voters"].ToInt();
            FStatus = oDB["status"].ToInt();
            FSortNum = oDB["sortnum"].ToDecimal();
            FInMan = oDB["inman"].ToString();
        }
        oDB.Free();
    }
    //插入新记录。
    public void Insert()
    {
        string ExSql = "'" + FId + "','" + FTitle + "','" + FDescription + "','" + FType + "','" + FEndTime + "','" + FAuthority + "','" + FVoters + "','" + FStatus + "','" + FSortNum + "','" + FInMan + "','" + FInTime + "'";
        base.Insert(ExSql);
    }
    //更新记录。
    public void Update()
    {
        string ExSql = " title ='" + FTitle + "', description ='" + FDescription + "', type ='" + FType + "', endtime ='" + FEndTime + "', authority ='" + FAuthority + "', voters='" + FVoters + "', status ='" + FStatus + "', sortnum ='" + FSortNum + "', inman ='" + FInMan + "', intime ='" + FInTime + "'"; 
        base.Update(ExSql);
    }
    //改变状态,0=未验证,1=已通过验证
    public void Update_status()
    {
        string ExSql = "status=" + FStatus.ToString(); ;
        base.Update(ExSql);
    }
    //静态，可以不用创建对象即可调用。
    public static void DeleteByID(string sID)
    {
        TData.DeleteByID(sID, CTableName, CKeyName);
    }


    public string Id
    {
        get
        {
            return FId;
        }
        set
        {
            FId = value;
        }
    }
    public DateTime InTime
    {
        get
        {
            return FInTime;
        }
        set
        {
            FInTime = value;
        }
    }
    public int IId
    {
        get
        {
            return FIId;
        }
        set
        {
            FIId = value;
        }
    }
    public string Title
    {
        get
        {
            return FTitle;
        }
        set
        {
            FTitle = value;
        }
    }
    public string Description
    {
        get
        {
            return FDescription;
        }
        set
        {
            FDescription = value;
        }
    }
    public int Type
    {
        get
        {
            return FType;
        }
        set
        {
            FType = value;
        }
    }
    public DateTime EndTime
    {
        get
        {
            return FEndTime;
        }
        set
        {
            FEndTime = value;
        }
    }
    public int Authority
    {
        get
        {
            return FAuthority;
        }
        set
        {
            FAuthority = value;
        }
    }
    public int Voters
    {
        get
        {
            return FVoters;
        }
        set
        {
            FVoters = value;
        }
    }
    public int Status
    {
        get
        {
            return FStatus;
        }
        set
        {
            FStatus = value;
        }
    }
    public decimal SortNum
    {
        get
        {
            return FSortNum;
        }
        set
        {
            FSortNum = value;
        }
    }
    public string InMan
    {
        get
        {
            return FInMan;
        }
        set
        {
            FInMan = value;
        }
    }
}
